% /*******************************************************************************
%  * Round Nearest
%  * *****************************************************************************
%  * E.g. 0.10(11) -> 0.1011*2^2 = 10.11 -> 11 -> 11/2^2 -> 0.11
%  * @param x     Input number in [0,1)
%  * @param bits  Significant bits(or #bit to keep)
%  * @return      Rounded number
%  */
function x_round = rnd_near(x, bits)
scale = 2^bits;
x_round = double(round(x * scale)/scale);
end